package 练习;

import java.util.Arrays;

/**
 * @Author Mucd
 * @ClassName Rabbit
 * @Date 2020/12/12/012
 * @Specification Alibaba
 */
public class Rabbit {
    public static void main(String[] args) {
        System.out.println(arr(20));
    }

    public static int arr(int month) {
        int[] rabbit = new int[month];

        //前两个个月还没生
        rabbit[0] = 1;
        rabbit[1] = 1;

        for (int i = 2; i < rabbit.length; i++) {
            //当前月兔子数 = 上个月兔子数+上上个月兔子数
            rabbit[i] = rabbit[i - 1] + rabbit[i - 2];
        }

        //索引从0开始,所以要 -1
        return rabbit[month - 1];
    }
}
